#include<stdio.h>
int main()
{
    int n,a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    int arr[n]; 
    int arr[n]={1,2,3,4,5,6,7,8,9,10};
 if(arr[n]%a!=0&&arr[n]%4!=0&&arr[n]%5!=0)
     printf("%d",arr[n]);
    return 0;
}
